package com.gt.web.srv.service.impl;

import com.gt.web.srv.domain.PaymentOrder;
import com.gt.web.srv.mapper.PaymentOrderMapper;
import com.gt.web.srv.service.PaymentOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>describe</p >
 *
 * @author shenhuiyang
 * @version 1.0
 * @date 2025/6/3 19:06
 * @menu describe
 */
@Service
public class PaymentOrderServiceImpl implements PaymentOrderService {
    @Autowired
    private PaymentOrderMapper paymentOrderMapper;

    @Transactional
    public Long createPaymentOrder(PaymentOrder paymentOrder) {
        paymentOrderMapper.insert(paymentOrder);
        return paymentOrder.getPayId();
    }

    @Transactional
    public int updatePaymentOrder(PaymentOrder paymentOrder) {
        return paymentOrderMapper.update(paymentOrder);
    }

    @Transactional
    public int deletePaymentOrder(Long payId) {
        return paymentOrderMapper.deleteById(payId);
    }

    public PaymentOrder getPaymentOrderById(Long payId) {
        return paymentOrderMapper.selectById(payId);
    }

    public PaymentOrder getPaymentOrderByOutTradeNo(String outTradeNo) {
        return paymentOrderMapper.selectByOutTradeNo(outTradeNo);
    }

    public List<PaymentOrder> getPaymentOrderList(PaymentOrder paymentOrder) {
        return paymentOrderMapper.selectList(paymentOrder);
    }

    @Transactional
    public int updateTradeStatus(Long payId, Integer tradeStatus, String returnMsg) {
        return paymentOrderMapper.updateTradeStatus(payId, tradeStatus, returnMsg);
    }

    @Transactional
    public int updatePrepayId(Long payId, String prepayId) {
        return paymentOrderMapper.updatePrepayId(payId, prepayId);
    }
}
